package com.hh.test.design.filter;

import java.util.ArrayList;
import java.util.List;

public class AgeFilter implements Filter {
	private int minAge;
	private int maxAge;

	public int getMinAge() {
		return minAge;
	}

	public void setMinAge(int minAge) {
		this.minAge = minAge;
	}

	public int getMaxAge() {
		return maxAge;
	}

	public AgeFilter(int minAge, int maxAge) {
		super();
		this.minAge = minAge;
		this.maxAge = maxAge;
	}

	public void setMaxAge(int maxAge) {
		this.maxAge = maxAge;
	}

	@Override
	public List<Person> filter(List<Person> persons) {
		List<Person> l = new ArrayList<>();
		for (Person p : persons) {
			if (p.getAge() > this.getMinAge() && p.getAge() < getMaxAge()) {
				l.add(p);
			}
		}
		return l;
	}

}
